// add by yanyj 20180725 start
// fetch 封装类
class Fetch {
    constructor(url) {
        this.prefix = url || ''; // url 前缀
        this._fetch = fetch;
    }

    // get 方法
    get(url, data) {
        let params = '?';
        let keys = pocket.keys(data);
        pocket.forEach(keys, key => {
            params += `${key}=${data[key]}?`
        });
        params = params.slice(0, params.length - 1);
        return this._fetch(this.prefix + url + params, {credentials: 'include'});
    }

    // postFetch
    post(url, data) {

        return this._fetch(this.prefix + url, {
            credentials: 'include',
            method: 'post',
            body: JSON.stringify(data),
            // 设置body类型
            headers: {
                'content-type': 'application/json; charset=UTF-8',
            }
        });
    }
}

// add by yanyj 20180725 end